﻿/*
 * @Autor: PK
 * @Date: 2022/01/14 22:13:SS
 */

using System.Collections.Generic;
using O2DESNet;
using ShkSimulation.core.dao.statistic;
using ShkSimulation.carsharing;
using ShkSimulation.core.template.customer;
using ShkSimulation.core.template.model;

namespace ShkSimulation.carsharing.efficiency {

	public class EvaluationStation: CarsharingStation {
		
		public int RejectCount { get; set; }
		public int ArriveCount { get; set; }
		public int DepartCount { get; set; }
		public int FinishedCount { get; private set; }

		private Dictionary<string, ReadOnlyHourCounter> NamedHourCounters = new Dictionary<string, ReadOnlyHourCounter>();

		public EvaluationStation(BaseAgencyParams agencyParams) : base(agencyParams) {
		}

		public override ServiceRateHelper ServiceRateHelper { get; set; }

		public override DataReportInfo GetReportInfo() {
			Dictionary<string, double> doubleValues = new Dictionary<string, double>();
			doubleValues.Add("ArriveCount", ArriveCount);
			doubleValues.Add("RejectCount", RejectCount);
			doubleValues.Add("FinishedCount", FinishedCount);
			return DataReportInfo.Create(UniqueId.ToString(), ClockTime, NamedHourCounters, doubleValues);
		}

		public override void TravelerArrive(CarsharingTraveler customer) {
			EvaluationTraveler traveler = (EvaluationTraveler)customer;
			if (traveler.WithVehicle) {
				FinishedCount++;
				return;
			}
			ArriveCount++;
			traveler.StartTime = ClockTime;
			traveler.WithVehicle = true;
			InternalServe(traveler);
		}

		public override void TravelerServe(CarsharingTraveler customer) {
			ScheduleDepart(customer, ServiceRateHelper.GetAverageServiceTime());
		}

		public override void TravelerDepart(CarsharingTraveler customer) {
			DepartCount++;
			customer.EnterNextAgency();
		}

	}

}